package com.site.util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;

/**
 * @author xiaochi
 * @date 2022/5/11 14:51
 */
public class OrderUtil {

    /**
     * 生成订单（不重复）
     * @return
     */
    public static String orderNo() {
        int machineId = 1;//最⼤⽀持1-9个集群机器部署
        int hashCodeV = UUID.randomUUID().toString().hashCode();
        if(hashCodeV < 0){
            hashCodeV = -hashCodeV;
        }
        return LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + machineId + String.format("%012d",hashCodeV);
    }
}
